from pyquery import PyQuery as pq
# doc = pq(url="https://www.baidu.com", encoding="utf-8")
# print(doc("title"))
# 功能相同
# import requests
# doc = pq(requests.get("https://www.baidu.com").text)
#
# # 初始化本地文件, 指定filename
# doc = pq(filename="demo.html")

# items = doc(".app")
# subs = items.find("li")

html = """
<ul>
    <li></li>
    <li></li>
    <li></li>
    <li>wenben</li>
    <li></li>
</ul>"""
doc = pq(html)
li = doc("li:first-child")
print(li)
li = doc("li:last-child")
print(li)
li = doc("li:nth-child(2)")
print(li)
li = doc("li:gt(2)")
print(li)
li = doc("li:nth-child(2n)")
print(li)
li = doc("li:contains(wenben)")
print(li)
